#!/usr/bin/python3
# 文件名：server.py

# 导入 socket、sys 模块
import socket
import sys




BUFSIZE = 1024
# 创建 socket 对象
svr = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# 获取本地主机名
host = socket.gethostname()

port = 9999

# 绑定端口号
svr.bind(('0.0.0.0', port))


while True:
    dat,server_addr = svr.recvfrom(BUFSIZE)
    print(server_addr)
    type(server_addr)
    print(server_addr[0])
    print(dat)
    svr.sendto(server_addr[0].encode('utf-8'),server_addr)